package net.pulseproject.router.modules.useable;

import java.util.Collection;
import java.util.Collections;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import net.pulseproject.commons.midi.Receivable;
import net.pulseproject.commons.midi.Transmitable;
import net.pulseproject.commons.midi.entity.MidiSocket;
import net.pulseproject.router.modules.MidiModule;

public class MidiTransmitterModule extends MidiModule implements Transmitable {
	
	private static final Log LOG = LogFactory.getLog(MidiTransmitterModule.class);
	
	private final Collection<Receivable> outgoingModules;
	
	public MidiTransmitterModule(final String id, final MidiSocket socket, final Collection<Receivable> outgoingModules) {
		super(id, socket);
		LOG.debug("new MidiTransmitterModule(id="+id+", socket="+socket+", outgoingModules)");
		if(outgoingModules == null) { throw new IllegalArgumentException("outgoingModules == null"); }
		this.outgoingModules = Collections.unmodifiableCollection(outgoingModules);
	}

	@Override
	public final Collection<Receivable> getOutgoingModules() {
		return this.outgoingModules;
	}

	@Override
	public final String toString() {
		return "MidiTransmitterModule[id=" + this.getId() + ", socket=" + this.getSocket() + ", " +
				"outgoingModules.size=" + this.outgoingModules.size() + "]";
	}

}
